import ajax from "axios";
import qs from "qs";

export function fromFetch(url, data, method = "post") {
  return ajax({
    url,
    method,
    headers: {
      // 'content-type': 'application/x-www-form-urlencoded',
      "X-Requested-With": "XMLHttpRequest",
    },
    data: qs.stringify(data),
  });
}

//table表格内容的转换,不需要render函数渲染
export const transList = (data) => {
  if (typeOf(data) !== "array") return [];
  const statusMap = {
    1: "排队准备",
    2: "执行中",
    3: "已完成",
    4: "异常已回滚",
  };
  return data.map((it) => {
    return {
      ...it,
      statusText: statusMap[it.status],
      isReloadText: it.isReload === "1" ? "是" : "非",
    };
  });
};
